<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>游戏管理</title>
	<%@ include file="/view/common/tags.jsp"%>
	<script type="text/javascript" src="${sysManagerV1}/js/My97DatePicker/WdatePicker.js"> </script>
</head>
<body>
	<section class="content">
        <c:set var="pageId" value='<%=request.getParameter("pageId")%>'/>
        <c:set var="userId" value='<%=request.getParameter("rowId")%>'/>
        <ul class="nav nav-tabs" role="tablist" id="tabList">
            <li role="presentation" id="jsTab" class="active">
                <a href="javascript:void(0);" onclick="clubTabSwitch(10)" role="tab" data-toggle="tab">俱乐部</a>
            </li>
        </ul>
    	<div class="row">
            <div class="col-md-12">
                <div class="box">
                	<div class="box-body">
                        <ul class="nav nav-tabs" role="tablist" id="teamList">
                            <li role="presentation" id="jsTab" class="active">
                                <a href="javascript:void(0);" onclick="tabSwitch(10)" role="tab" data-toggle="tab">战队</a>
                            </li>
                        </ul>
						<div class="panel panel-default" >
                            <div class="form-group">
                                <label class="col-xs-12 text-left">队员信息</label>
                            </div>
                            <div class="panel-body" style="padding-bottom:5px; padding:0px;">
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">帐号：</label>
                                    <label class="col-xs-2" id="userAccount"></label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">昵称：</label>
                                    <label class="col-xs-2" id="nickname"></label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">联系QQ：</label>
                                    <label class="col-xs-2" id="linkQq"></label>
                                </div>
                        	</div>
                            <div class="panel-body" style="padding-bottom:5px; padding:0px;">
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">游戏角色名称：</label>
                                    <label class="col-xs-2" id="gameRole"></label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">总余额：</label>
                                    <label class="col-xs-2" id="userBalance">0.00</label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">累计充值：</label>
                                    <label class="col-xs-2" id="userRechangeSum">0.00</label>
                                </div>
                        	</div>
                            <div class="panel-body" style="padding-bottom:5px; padding:0px;">
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">参赛总数：</label>
                                    <label class="col-xs-2" id="userMatchAmount">0.00</label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">获奖总数：</label>
                                    <label class="col-xs-2" id="userWinAmount">0</label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">获奖总额：</label>
                                    <label class="col-xs-2" id="userWinSum">0</label>
                                </div>
                        	</div>
                          
                          <!-- 所在俱乐部 -->
						    <hr/>
                            <div class="form-group">
                                <label class="col-xs-12 text-left" style="margin-top: -10px;">所在俱乐部</label>
                            </div>
                            <div class="panel-body" style="padding-bottom:5px; padding:0px;">
                                <div class="form-group">
                                    <label class="col-xs-3 text-right">所在俱乐部总额：</label>
                                    <label class="col-xs-3" id="userClubBalance">0.00</label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-3 text-right">累计充值：</label>
                                    <label class="col-xs-3" id="clubRechangeSum">0.00</label>
                                </div>
                        	</div>
                            <div class="panel-body" style="padding-bottom:5px; padding:0px;">
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">参赛总数：</label>
                                    <label class="col-xs-2" id="clubMatchAmount">0</label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">获奖总数：</label>
                                    <label class="col-xs-2" id="clubWinAmount">0</label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">获奖总额：</label>
                                    <label class="col-xs-2" id="clubWinSum">0.00</label>
                                </div>
                        	</div>
                          
                          <!-- 所在战队 -->
						    <hr/>
                            <div class="form-group">
                                <label class="col-xs-12 text-left" style="margin-top: -10px;">所在战队</label>
                            </div>
                            <div class="panel-body" style="padding-bottom:5px; padding:0px;">
                                <div class="form-group">
                                    <label class="col-xs-3 text-right">所在战队总额：</label>
                                    <label class="col-xs-3" id="userTeamBalance">0.00</label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-3 text-right">累计充值：</label>
                                    <label class="col-xs-3" id="teamRechangeSum">0.00</label>
                                </div>
                        	</div>
                            <div class="panel-body" style="padding-bottom:5px; padding:0px;">
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">参赛总数：</label>
                                    <label class="col-xs-2" id="teamMatchAmount">0</label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">获奖总数：</label>
                                    <label class="col-xs-2" id="teamWinAmount">0</label>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-2 text-right">获奖总额：</label>
                                    <label class="col-xs-2" id="teamWinSum">0.00</label>
                                </div>
                        	</div>
						</div>
                    </div>
                </div>
            </div>
       	</div>
	</section>
   <%@ include file="/view/common/footer.jsp"%>
</body>
<script>
	// 提示信息
	var msgg='<%=request.getAttribute("msg")%>';
	if (msgg && msgg!=null && msgg!='null') { 
		  layer.msg(msgg);
	}
	var tableIndex = 0;
	var data = "";
	var clubId;
	
    $(function(){
    	// 加载table 数据
    	var token = sessionStorage.getItem("token");
        $.ajax({
            url: "${sysManagerV1}/pubgUser/getUserDetail?rowId=${userId}&token=" + token,
            type: "post",
            cache: false,
            dataType:"json",
            async:false,
            success: function(result) {
                //alert(JSON.stringify(result));
            	if(result.code != 0){
            		layer.msg(result.message);
            		return;
            	}
                data = result;
                
                // 填充用户信息
                var userData = result.data.userData;
                $("#userAccount").html(userData.userAccount);
                $("#nickname").html(userData.nickname);
                $("#linkQq").html(userData.linkQq);
                $("#gameRole").html(userData.gameRole);
                $("#userRechangeSum").html(userData.rechangeSum);
                $("#userMatchAmount").html(userData.matchAmount);
                $("#userWinAmount").html(userData.winAmount);
                $("#userWinSum").html(userData.winSum);
                
                // 俱乐部 标签
                var clubHtml = '';
                var clubOneData = "";
                var clubData = result.data.clubData;
                for(var index in clubData){
                	if(index == 0){
                		clubOneData = clubData[0];
                		clubId = clubOneData.clubId;
                	}
                	clubHtml += '<li role="presentation" id="clubTab' + index + '" class="' + (index == 0 ? 'active' : '') + '">';
                	clubHtml += '<a href="javascript:void(0)" onclick="clubTabSwitch(' + clubData[index].clubId + ')" role="tab" data-toggle="tab">' + clubData[index].clubName + '</a>';
                	clubHtml += '</li>';
                    $("#tabList").html(clubHtml);
                }
                
                // 填充俱乐部信息
                $("#userClubBalance").html(clubOneData.userClubBalance);
                $("#clubRechangeSum").html(clubOneData.rechangeSum);
                $("#clubMatchAmount").html(clubOneData.matchAmount);
                $("#clubWinAmount").html(clubOneData.winAmount);
                $("#clubWinSum").html(clubOneData.winSum);
                
                // 战队标签
                var teamHtml = "";
                var teamDataKey = "";
                var teamData = result.data["club" + clubOneData.clubId + "team"];
                for(var index in teamData){
                	if(index == 0){
                		teamDataKey = "club" + clubOneData.clubId + "team" + teamData[0].teamId; 
                	}
                	teamHtml += '<li role="presentation" id="teamTab' + index + '" class="' + (index == 0 ? 'active' : '') + '">';
                	teamHtml += '<a href="javascript:void(0)" onclick="teamTabSwitch(' + teamData[index].teamId + ')" role="tab" data-toggle="tab">' + teamData[index].teamName + '</a>';
                	teamHtml += '</li>';
                }
                $("#teamList").html(teamHtml);
                
                // 填充战队信息
                var teamOneData = result.data[teamDataKey];
                //alert(JSON.stringify(teamOneData));
                $("#userTeamBalance").html(teamOneData.userTeamBalance);
                $("#teamRechangeSum").html(teamOneData.rechangeSum);
                $("#teamMatchAmount").html(teamOneData.matchAmount);
                $("#teamWinAmount").html(teamOneData.winAmount);
                $("#teamWinSum").html(teamOneData.winSum);
            }
        });
    })

    // 俱乐部table页切换
    function clubTabSwitch(id){
    	var teamDataKey = "club" + id + "team";
    	
    	var teamHtml = "";
    	var teamData = data.data[teamDataKey];
    	for(var index in teamData){
            if(index == 0){
                teamDataKey = "club" + id + "team" + teamData[0].teamId; 
            }
            teamHtml += '<li role="presentation" id="jsTab' + index + '" class="' + (index == 0 ? 'active' : '') + '">';
            teamHtml += '<a href="javascript:void(0)" onclick="teamTabSwitch(' + teamData[index].teamId + ')" role="tab" data-toggle="tab">' + teamData[index].teamName + '</a>';
            teamHtml += '</li>';
        }
        $("#teamList").html(teamHtml);

        // 填充俱乐部信息
        var clubOneData = "";
        var clubData = data.data.clubData;
        for(var index in clubData){
            if(clubData[index].clubId == id){
                clubOneData = clubData[index];
                clubId = clubOneData.clubId;
            }
        }
        $("#userClubBalance").html(clubOneData.userClubBalance);
        $("#clubRechangeSum").html(clubOneData.rechangeSum);
        $("#clubMatchAmount").html(clubOneData.matchAmount);
        $("#clubWinAmount").html(clubOneData.winAmount);
        $("#clubWinSum").html(clubOneData.winSum);
        
        // 填充战队信息
        var teamOneData = data.data[teamDataKey];
        $("#userTeamBalance").html(teamOneData.userTeamBalance);
        $("#teamRechangeSum").html(teamOneData.rechangeSum);
        $("#teamMatchAmount").html(teamOneData.matchAmount);
        $("#teamWinAmount").html(teamOneData.winAmount);
        $("#teamWinSum").html(teamOneData.winSum);
    }

    // 战队table页切换
    function teamTabSwitch(id){
    	var teamDataKey = "club" + clubId + "team" + id;
        
    	var teamData = data.data[teamDataKey];
    	//alert(JSON.stringify(teamData));
    	
        // 填充战队信息
        var teamOneData = data.data[teamDataKey];
        $("#userTeamBalance").html(teamOneData.userTeamBalance);
        $("#teamRechangeSum").html(teamOneData.rechangeSum);
        $("#teamMatchAmount").html(teamOneData.matchAmount);
        $("#teamWinAmount").html(teamOneData.winAmount);
        $("#teamWinSum").html(teamOneData.winSum);
        
    }
</script>
</html>